package com.szcinda.service.dto.analysis;

import lombok.Data;

import java.io.Serializable;

@Data
public class OrderProfitDto implements Serializable {
    public String id;
    public String organizationId;
    public String organizationName;
    private String clientId;
    private String clientName;
    private double inTransportFeeOfRMB;
    private double inTransportFeeOfUSD;
    private double inOtherOfRMB;
    private double inOtherOfUSD;
    private double inAmount;
    private String carrierName;
    private double outTransportFeeOfRMB;
    private double outTransportFeeOfUSD;
    private double outOtherOfRMB;
    private double outOtherOfUSD;
    private double outAmount;
    private double profit;

    public void addOutFee(String currency, String feeName, double fee) {

        if ("美元".equals(currency) || "USD".equals(currency)) {
            if (feeName.contains("运输费")) {
                this.outTransportFeeOfUSD = this.outTransportFeeOfUSD + fee;
            } else {
                this.outOtherOfUSD = this.outOtherOfUSD + fee;
            }
        } else if ("人民币".equals(currency) || "RMB".equals(currency)) {
            if (feeName.contains("运输费")) {
                this.outTransportFeeOfRMB = this.outTransportFeeOfRMB + fee;
            } else {
                this.outOtherOfRMB = this.outOtherOfRMB + fee;
            }
        }
    }

    public void calculateProfit() {
        this.profit = this.inAmount - this.outAmount;
    }
}
